#include <iostream>
#include <string>
#include <vector>

extern "C" {
    #include <stdint.h>
};

using namespace std;

inline void desenhar(vector<uint8_t> posicoes, int tam) {

    // Linha 1 [Begin]
        for (vector<uint8_t>::iterator i = posicoes.begin(); i != posicoes.end(); ++i) {

            if (*i & 1)
                cout << ' ' << string(tam,'-') << ' ';
            else
                cout << string(tam+2,' ');

            if (i != posicoes.begin()
                && i + 1 != posicoes.end())
                cout << ' ';
        }
    // Linha 1 [End]

    cout << '\n';

    // Linha 2 [Begin]
    ///

    for (int j=0; j != tam; ++j) {
        for (vector<uint8_t>::iterator i=posicoes.begin(); i != posicoes.end(); ++i) {


            if (*i & 32)
                cout << '|';
            else
                cout << ' ';

            cout << string(tam,' ');
            
            if (*i & 2)
                cout << '|';
            else
                cout << ' ';

            if (i != posicoes.begin()
                && i + 1 != posicoes.end())
                cout << ' ';
        }
        cout << '\n';
    }
    ///
    // Linha 2 [End]



    // Linha 3 [Begin]
        for (vector<uint8_t>::iterator i=posicoes.begin(); i != posicoes.end(); ++i) {

            if (*i & 64)
                cout << ' ' << string(tam,'-') << ' ';
            else
                cout << string(tam+2,' ');

            if (i != posicoes.begin()
                && i + 1 != posicoes.end())
                cout << ' ';
        }
    // Linha 3 [End]

    cout << '\n';

    // Linha 4 [Begin]
    ///
    for (int j=0; j != tam; ++j) {
        for (vector<uint8_t>::iterator i=posicoes.begin(); i != posicoes.end(); ++i) {


            if (*i & 16)
                cout << '|';
            else
                cout << ' ';

            cout << string(tam,' ');
            
            if (*i & 4)
                cout << '|';
            else
                cout << ' ';

            if (i != posicoes.begin()
                && i + 1 != posicoes.end())
                cout << ' ';
        }
        cout << '\n';
    }
    ///
    // Linha 4 [End]
    

    // Linha 5 [Begin]
        for (vector<uint8_t>::iterator i=posicoes.begin(); i != posicoes.end(); ++i) {

            if (*i & 8)
                cout << ' ' << string(tam,'-') << ' ';
            else
                cout << string(tam+2,' ');

            if (i != posicoes.begin()
                && i + 1 != posicoes.end())
                cout << ' ';
        }
    // Linha 5 [End]

    cout << '\n';
}


inline void print(string str, int size)
{
  vector<uint8_t> number(str.size(), 0);

  for (int i = 0;i != str.size();++i) {
    switch (str[i]) {
    case '0':
    case '2':
    case '3':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':
      number[i] |= 1;
    }
    switch (str[i]) {
    case '0':
    case '4':
    case '5':
    case '6':
    case '8':
    case '9':
      number[i] |= 32;
    }
    switch (str[i]) {
    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '7':
    case '8':
    case '9':
      number[i] |= 2;
    }
    switch (str[i]) {
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '8':
    case '9':
      number[i] |= 64;
    }
    switch (str[i]) {
    case '0':
    case '1':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':
      number[i] |= 4;
    }
    switch (str[i]) {
    case '0':
    case '2':
    case '3':
    case '5':
    case '6':
    case '8':
    case '9':
      number[i] |= 8;
    }
    switch (str[i]) {
    case '0':
    case '2':
    case '6':
    case '8':
      number[i] |= 16;
    }
  }

  desenhar(number, size);

}


int main () {

int s;
string n;


while (cin >> s >> n
    && n != "0" && s) {

print(n, s);
    
return 0;
}
